package lucky.xiong.basic.编码;

import cn.hutool.http.HttpUtil;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

public class GBK {
    public static void main(String[] args) throws UnsupportedEncodingException {
//        String gbkStr = "你好，你的验证码为：123456";
//
//        String encode = URLEncoder.encode(gbkStr, "gbk");
//        System.out.println(encode);
//
//        String decode = URLDecoder.decode("%D7%F0%BE%B4%B5%C4%B2%E2%CA%D4%D3%C3%BB%A7%3A%C4%FA%B5%C4%B6%AF%CC%AC%BF%DA%C1%EE%CE%AA%A3%BA1234%2C60%B7%D6%D6%D3%C4%DA%D3%D0%D0%A7%A3%A1", "gbk");
//        System.out.println(decode);

        HashMap<String, Object> paramMap = new HashMap<>();
        paramMap.put("command", "sendSMSMD5");
        paramMap.put("username", "18483652558");
        paramMap.put("pwd", "147672B1001961204802C90273C7855A");
        paramMap.put("mobiles", "18483652558");
//        try {
            paramMap.put("content", URLEncoder.encode("你好", "gbk"));
//        paramMap.put("content","你好你好");
//        } catch (UnsupportedEncodingException e) {
//            throw new CodedException(IErrorCode.ENCRYPTION_ERROR, e);
//        }
        paramMap.put("incode", "GBK");
        paramMap.put("outcode", "GBK");
        paramMap.put("pfex", 0);
//        Map<String, String> headers = new HashMap<>();
//        headers.put("Content-Type", "application/x-www-form-urlencoded; charset=GBK");
        String result = HttpUtil.createPost("http://www.sjzqzx.com/MessagePlat/smsSendServlet.htm")
                .header("Content-Type", "application/x-www-form-urlencoded; charset=GBK")
                .form(paramMap)
                .execute().body();
        System.out.println(result);
    }
}
